<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=505915
-->
<head>
  <title>Test for Bug 505915</title>
  <script type="application/javascript" src="/MochiKit/packed.js"></script>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=505915">Mozilla Bug 505915</a>
<p id="display"></p>
<div id="content" style="display: none">
  
</div>
<pre id="test">
<script type="application/javascript">

/** Test for Bug 505915 **/

function go() {
    var ifr = $('ifr');
    try {
        document.documentElement.appendChild(ifr.contentWindow);
        ok(false, "weird behavior");
    } catch (e) {
        ok(/NS_ERROR_XPC_SECURITY_MANAGER_VETO/.test(e),
           "threw a security exception instead of an invalid child exception");
    }

    try {
        document.createTreeWalker(ifr.contentDocument, 0, null, false);
        ok(false, "should have thrown a security exception");
    } catch (e) {
        ok(/NS_ERROR_XPC_SECURITY_MANAGER_VETO/.test(e),
           "threw a security exception instead of an invalid child exception");
    }

    var xhr = new XMLHttpRequest();
    var orsc = new XPCSafeJSObjectWrapper(function(){});
    xhr.onreadystatechange = orsc;
    // we only can test that the above didn't throw (which it shouldn't).

    try {
        xhr.onreadystatechange = ifr.contentWindow;
        ok(false, "weird behavior");
    } catch (e) {
        ok(/NS_ERROR_XPC_SECURITY_MANAGER_VETO/.test(e),
           "threw a security exception instead of an invalid child exception");
    }

    SimpleTest.finish();
}

SimpleTest.waitForExplicitFinish();

</script>
</pre>

<iframe id="ifr" onload="go()" src="http://example.org/"></iframe>

</body>
</html>
